import weibo_request as wr

#_______________________________________________________________________________________________________________________
#@ 类
class WEIBO_CONSOLE(object):
    #___________________________________________________________________________________________________________________
    #@ 类变量
    obj_weibo_request   = wr.WEIBO_REQUESTS()
    #___________________________________________________________________________________________________________________
    #@ 初始化
    def __init__(self):
        pass
    #___________________________________________________________________________________________________________________
    #@ main：控制台查阅
    def console_uid_by_nickname_and_exact(self):
        while(1):
            #// 1. 输入姓名
            print("\n")
            name = input('请输入昵称（exit退出）：')
            # print("\n")
            #// 2. 确认退出
            if name == 'exit':
                break
            #// 3. 标志
            flag = False
            #// 4. try
            try:
                #// 4. 获取响应
                data = self.obj_weibo_request.get_uid_by_nickname_and_exact(name,1)
                #// 5. 响应1
                if data['ok']==0:
                    print('没有相关昵称！')
                    continue
                #// 6. 确认数据位置
                dataset = data['data']['cards'][1]['card_group']
                #// 7. 寻找对应昵称
                for j in dataset:
                    #// 1. 响应2
                    if j['user']['screen_name'] != name:
                        # print('（X）'+name+" —— "+j['user']['screen_name'])
                        continue
                    #// 2. 响应3
                    flag = True
                    print("--------------------------------------------")
                    print("ID："+str(j['user']['id']))
                    print("昵称："+str(j['user']['screen_name']))
                    print("简介："+str(j['user']['description']))
                    print("是否认证："+str(j['user']['verified']))
                    print("认证类型："+str(j['user']['verified_type']))
                    try:
                        print("认证信息："+str(j['user']['verified_reason']))
                    except:
                        print("认证信息："+"无")
                    print("-------------------------------------------------------------------------------------------")
                    break
                if flag == False:
                    print("没有该昵称！")
            except:
                print("运行异常！")